package leecode

import (
	"strconv"
	"strings"
)

func countBits(n int) []int {
	var result []int
	for i := 0; i <= n; i++ {
		str := strconv.FormatInt(int64(i), 2)
		count := strings.Count(str, "1")
		result = append(result, count)
	}
	return result
}
